﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ARR.Entities.Validation.ComponentModel;
using ARR.Entities.ComponentModel;
using ARR.Entities.Validation.Common;
using ARR.Shared;

namespace ARR.Entities.Validation
{
    [Serializable]
    public class RangeReviewBenchmarksInputValidations : InputValidationBase
    {
        RangeReviewBenchmark benchmark;

        public RangeReviewBenchmarksInputValidations(RangeReviewBenchmark benchmark)
        {
            this.benchmark = benchmark;
        }

        public override List<ValidationBase> CreateValidations()
        {
            List<ValidationBase> inputValidations = new List<ValidationBase>();

            inputValidations.Add(new CustomValidation("RangeReviewSourceId", string.Format(Errors.RequiredValidation, Labels.RangeReviewOrigen), delegate()
            {
                if (benchmark.GetEntityState() == DDF.Entity.EntityState.New)
                {
                    return true;
                }
                else
                {
                    return benchmark.RangeReviewSourceId > 0;
                }

                
            }));
            
            inputValidations.Add(new CustomValidation("TargetCurrencyId", string.Format(Errors.RequiredValidation, Labels.MonedaTiendas), delegate()
            {
                return benchmark.TargetCurrencyId > 0;
            }));                
            

            return inputValidations;
        }
    }
}
